package org.threebitsoftware.tbb.module.simpletext;

import junit.framework.TestCase;

import java.util.Vector;
import org.threebitsoftware.tbb.dao.*;

public class SimpleTextImporterTest extends TestCase {

	public void testParseFile() {
		
		Contact[] myContacts = null;
		SimpleTextImporter importContactsFromFile = new SimpleTextImporter();
		String myStrFilePath = new String("C:\\Users\\ABBA\\My Documents\\Downloads\\contacts.txt");
		
		try {
			
			myContacts = importContactsFromFile.parseFile(myStrFilePath);
			
			System.out.println("There are " + myContacts.length + " contacts:");
			System.out.println();
			
			int contactIndex = 1;
			for (Contact myContact : myContacts) {
				System.out.println("Contact #" + contactIndex);
				System.out.println("User Application ID:" + myContact.getIdAppUser());
				System.out.println("Contact ID:" + myContact.getIdContact());
				
				System.out.println("Name");
				
				String titleStr = myContact.getTitle();
				String prefixStr = myContact.getPrefix();
				String firstStr = myContact.getFirstName();
				String middleStr = myContact.getMiddleName();
				String lastStr = myContact.getLastName();
				String suffixStr = myContact.getSuffix();
				String companyStr = myContact.getCompany();
				
				if (!prefixStr.isEmpty()) {
					System.out.println("    Prefix: " + prefixStr);
				}
				
				if (!firstStr.isEmpty()) {
					System.out.println(" Firstname: " + firstStr);
				}
				
				if (!middleStr.isEmpty()) {
					System.out.println("Middlename: " + middleStr);
				}
				
				if (!lastStr.isEmpty()) {
					System.out.println("  Lastname: " + lastStr);
				}
				
				if (!suffixStr.isEmpty()) {
					System.out.println("    Suffix: " + suffixStr);
				}
				
				if (!titleStr.isEmpty()) {
					System.out.println("     Title: " + titleStr);
				}
				
				if (!companyStr.isEmpty()) {
					System.out.println("   Company: " + companyStr);
				}
				
				System.out.println();
				System.out.println("Addresses");
				for (Address address : myContact.getAddresses()) {
					System.out.println(address.toString());
				}
				
				System.out.println();
				System.out.println("Telephone Numbers");
				for (PhoneNumber phone : myContact.getPhoneNumbers()) {
					System.out.println(phone.toString());
				}
				
				System.out.println();
				System.out.println("Email Addresses");
				for (EmailAddress email : myContact.getEmails()) {
					System.out.println(email.toString());
				}
				
				contactIndex++;
				System.out.println();
			}
			
		} catch (Exception e) {
			fail("Exception found. Contacts were not imported from file");
			e.printStackTrace();
		}
	}

	public void testGetGUI() {
		fail("Not yet implemented");
	}

	public void testGetMergeClassName() {
		fail("Not yet implemented");
	}

	public void testIHaveMyOwnGUI() {
		fail("Not yet implemented");
	}

}
